#include<stdio.h>
#include"process.h"
#include<string.h>
#include<unistd.h>

#define NUM 101


void Process(double current, double total)
{
 double rate = current/total*100;
char bar[100];memset(bar , '\0',sizeof(bar)/sizeof(char));
int i ;
for( i = 0 ; i < (int)rate ; i++)
{
 bar[i] = '#';
}

char point[3];
memset(point,'\0',sizeof(point)/sizeof(char));
int n = (int)rate%3+1;
int j;
for(j = 0 ; j < n ; j++)
{
 point[j] = '.';
}

point[n] = '\0';
printf("[%-100s][%.1lf%%]%-4s\r",bar,rate,point);
fflush(stdout);
}





//
//void process()
//{
//char bar[NUM];
//memset(bar,'\0',sizeof(bar));
//int cnt = 0;
//    const char *label = "|/-\\";
//int len  =strlen(label) ;
//while(cnt <= 100)
//{
//    printf("[%-100s][%d%%][%c]\r",bar,cnt,label[cnt%len]);
//    fflush(stdout);
//    bar[cnt++] = '=';
//    if(cnt == 101) break;
//    bar[cnt] = '>';
//    
//    usleep(10000);
//}
//printf("\r\n");
//}
